<template>
  <div class="sub-menu scroll-item">
    <ul class="sub-menu-nav">
      <li v-for="(item, index) in subMenu" :class="{'activate-sub-menu': item.icon === isSubMenu}" @click="isSubMenu = item.icon">
        <i class="iconfont" :class="item.icon"></i>{{item.text}}</li>
    </ul>
    <!-- 新游速递  -->
    <div class="sub-menu-content" v-show="isSubMenu === 'icon-xin'" v-swiper:newSwiper="newGameSwiper">
      <div class="swiper-wrapper">
        <div class="swiper-slide content-item" v-for="(item, index) in Home.newGame">
          <a :href="item.link">
            <i v-lazy:background-image="item.icon"></i>
            <p>{{item.name}}</p>
          </a>
        </div>
      </div>
    </div>
    <div class="sub-menu-content" v-show="isSubMenu === 'icon-huo'" v-swiper:hotSwiper="hotDownSwiper">
      <div class="swiper-wrapper">
        <div class="swiper-slide content-item" v-for="(item, index) in Home.hotDown">
          <a :href="item.link">
            <i v-lazy:background-image="item.icon"></i>
            <p>{{item.name}}</p>
          </a>
        </div>
      </div>
    </div>
    <div class="sub-menu-content" v-show="isSubMenu === 'icon-zan'" v-swiper:mySwiper="choicestSwiper">
      <div class="swiper-wrapper">
        <div class="swiper-slide content-item" v-for="(item, index) in Home.choicest">
          <a :href="item.link">
            <i v-lazy:background-image="item.icon"></i>
            <p>{{item.name}}</p>
          </a>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isSubMenu: 'icon-xin',
      subMenu: [
        { icon: 'icon-xin', text: '新游速递', activate: true },
        { icon: 'icon-huo', text: '热门下载', activate: false },
        { icon: 'icon-zan', text: '精选推荐', activate: false }
      ],
      newGameSwiper: { slidesPerView: 8, spaceBetween: 36 },
      hotDownSwiper: { slidesPerView: 8, spaceBetween: 36 },
      choicestSwiper: { slidesPerView: 8, spaceBetween: 36 }
    }
  },
  computed: {
    Home: function() {
      console.log(JSON.stringify(this.$store.state.Home))
      return this.$store.state.mock
    }
  }
}
</script>

<style lang="less" scoped>
.sub-menu {
  height: 194px;
  background-color: #fff;
  overflow: hidden;
  position: relative;
  padding-left: 165px;
  margin-bottom: 50px;
  .sub-menu-nav {
    width: 165px;
    position: absolute;
    left: 0;
    top: 0;
    li {
      line-height: 62px;
      border-bottom: 1px solid #f5f5f5;
      color: #999;
      text-align: center;
      cursor: pointer;
      position: relative;
      i {
        margin-right: 10px;
        font-size: 20px;
        vertical-align: middle;
        color: #d4d4d4;
      }
      &:last-child {
        border-bottom: 0;
      }
      &:hover {
        color: #fff;
        background: #ffa93a;
        i {
          color: #fff;
        }
      }
    }
    .activate-sub-menu {
      background-color: #ffa93a;
      color: #fff;
      position: relative;
      &:before {
        content: '';
        width: 0;
        height: 0;
        border-top: 6px solid transparent;
        border-bottom: 6px solid transparent;
        border-right: 8px solid #fff;
        background-color: transparent;
        position: absolute;
        right: -1px;
        top: 26px;
      }
      i {
        color: #fff;
      }
    }
  }
  .sub-menu-content {
    padding: 30px;
    overflow: hidden;
    .content-item {
      a {
        display: block;
        &:hover {
          i {
            transform: translateY(-10px);
          }
          p {
            transform: translateY(-10px);
          }
        }
      }
      i {
        display: block;
        width: 88px;
        height: 88px;
        background-size: 100%;
        -webkit-transition: all 0.25s ease-in-out;
        transition: all 0.25s ease-in-out;
      }
      p {
        text-align: center;
        padding-top: 20px;
        font-weight: 600;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        width: 88px;
        font-size: 16px;
        -webkit-transition: all 0.25s ease-in-out;
        transition: all 0.25s ease-in-out;
      }
    }
  }
}
</style>


